﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace Core
{
    public static partial class contest
    {
        public static dynamic timeValid(string st, string et)
        {
            DateTime start_time = new DateTime();
            DateTime.TryParse(st,out start_time);
            DateTime over_time = new DateTime();
            DateTime.TryParse(et,out over_time);
            if (isDateTime(st) && isDateTime(et))
            {
                if (start_time > over_time)
                    return new
                    {
                        success = false,
                        msg = "比赛起始时间小于结束时间"
                    };
                else return new
                {
                    sucess = true,
                    isValue = true
                };
            }
            else return new
            {
                success = false,
                msg = "请输入正确的时间格式"
            };
        }
        public static bool isDateTime(string StrSource)
        {
            return Regex.IsMatch(StrSource, @"[1-2]{1}[0-9]{3}((-|\/|\.){1}(([0]?[1-9]{1})|(1[0-2]{1}))((-|\/|\.){1}((([0]?[1-9]{1})|([1-2]{1}[0-9]{1})|(3[0-1]{1})))( (([0-1]{1}[0-9]{1})|2[0-3]{1}):([0-5]{1}[0-9]{1}):([0-5]{1}[0-9]{1})(\.[0-9]{3})?)?)?)?$");
        }

    }
}
